//这个函数我们测试矩阵的分割操作
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include"Matrix_segmentation.h"

int main(){
    //我们创造一个10*10的单位阵
    float* test_val = 0;
    int* test_row = 0;
    int* test_col = 0;
    
    int size = 10;

    //创建三个数组
    test_val = (float *)malloc(size * sizeof(float));
    test_row = (int *)malloc((size+1) * sizeof(int));
    test_col = (int *)malloc(size * sizeof(int));

    //循环变量
    int i;
    for(i = 0; i < size; i++){
        test_val[i] = i;
        test_row[i] = i;
        test_col[i] = i;
    }

    test_row[size] = 10;

    //我们申请新的几个数组来存储上三角元素
    float* output_val = 0;
    int* output_row = 0;
    int* output_col = 0;

    output_val = (float *)malloc(size * sizeof(float));
    output_row = (int *)malloc((size + 1) * sizeof(int));
    output_col = (int *)malloc(size * sizeof(int));

    //初始化
    memset(output_val, 0, size * sizeof(float));
    memset(output_row, 0, (size + 1) * sizeof(int));
    memset(output_col, 0, size * sizeof(int));

    //创建输出的实际大小
    int output_size = 0;

    martix_csr_get_diag(test_val, test_row, test_col, size, size, output_val, output_row, output_col, &output_size);

    printf("output_row:");

    //打印输出
    for(i = 0; i < size + 1; i++){
        printf("%d ", output_row[i]);
    }

    printf("\n");

    printf("output_val:");

    for(i = 0; i < output_size; i++){
        printf("%f ", output_val[i]);
    }

    printf("\n");

    printf("output_col:");

    for(i = 0; i < output_size; i++){
        printf("%d ", output_col[i]);
    }

    printf("\n");

    return 0;
}